package it.mp.multitask.view;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class LinearLayoutElencoTask extends LinearLayout{

	private int posizioneFineRecentlyApplication=0;
	private int screenWidth=0;
	private int dimensioneViewAppoggio=0;
	
	public LinearLayoutElencoTask(Context context, AttributeSet attrs) {
		super(context, attrs); 
	}
	
	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {		
		if (this.getWidth()>0){			
			dimensioneViewAppoggio=screenWidth-(this.getWidth()-posizioneFineRecentlyApplication);
			ImageView v=new ImageView(this.getContext());
			v.setImageResource(it.mp.multitask.R.drawable.sfondo);
			v.setMinimumWidth(dimensioneViewAppoggio);				
			addViewInLayout(v, -1, new LayoutParams(dimensioneViewAppoggio, 1));			
		}				
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
	}
	
	protected void setPosizioneFineRecentlyApplication(int width){
		posizioneFineRecentlyApplication+=width;
	}
	
	protected int getPixelRecentlyApplication(){
		return posizioneFineRecentlyApplication;
	}
		
	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
	}
	
	public void setDisplayWidth(int screenWidth){
		this.screenWidth=screenWidth;
	}
	protected void onLayout(boolean changed, int l, int t, int r, int b) {		
		super.onLayout(changed, l, t, r, b);
	}
}
